const Service = require('egg').Service;

class UserService extends Service {
    async user_register(params) {
        const User = this.ctx.model.User,
            newUser = new User(params);
        console.log('7...........', newUser);
        return await this.ctx.model.User.saveUser(newUser);
    }
    async user_add(params) {
        const User = this.ctx.model.User,
            newUser = new User(params);
        return await this.ctx.model.User.saveUser(newUser);
    }
    async user_findById(id) {
        return await this.ctx.model.User.findById(id);
    }
    async user_unique(unique) {
        return await this.ctx.model.User.findByUnique(unique);
    }
    async user_mail(mail) {
        return await this.ctx.model.User.findByMail(mail);
    }
    async user_login(mail) {
        return await this.ctx.model.User.findByMail(mail);
    }
    async user_list() {
        return await this.ctx.model.User.findAll({});
    }
    async user_avatars(userId) {
        return await this.ctx.model.User.findById(userId);
    }
    async user_update(uid, params) {
        return await this.ctx.model.User.updateUser(uid, params);
    }
    async user_delete(uid) {
        return await this.ctx.model.User.deleteUser(uid);
    }
    async add_article(params) {
        return await this.ctx.model.User.add_article(params);
    }
    async del_article({uid, aid}) {
        return await this.ctx.model.User.del_article({uid, aid});
    }
    async add_collect({uid, aid}) {
        return await this.ctx.model.User.addCollect({uid, aid});
    }
    async cut_collect({uid, aid}) {
        return await this.ctx.model.User.cutCollect({uid, aid});
    }
}

module.exports = UserService;